//         
var map;
var markers = new Array();
var infowindow = null;
var map_center = new google.maps.LatLng(52.042500, 4.7220571); // LatLng
// van
// reeuwijk
// om te
// centreren
// Alle opties voor google maps
var myOptions = {
	minZoom : 8,
	zoom : 12,
	center : map_center,
	MapOptions : {
		keyboardShortcuts : false,
	},
	zoomControl : true,
	zoomControlOptions : {
		style : google.maps.ZoomControlStyle.BIG
	},
	mapTypeId : google.maps.MapTypeId.HYBRID,
	mapTypeControl : false,
	streetViewControl : false,
	GDirectionsOptions : {

	}
}
var store_locations = new Array();
// Dit wordt de array met alle LatLngs van alle leerlingen
store_locations = [ new google.maps.LatLng(52.042500, 4.7220571),
		new google.maps.LatLng(52.042500, 4.7320571),
		new google.maps.LatLng(52.052500, 4.7220571),
		new google.maps.LatLng(52.047500, 4.7220571),
		new google.maps.LatLng(52.032500, 4.7220571) ];

function initialize() {
	infowindow = new google.maps.InfoWindow();

	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	// Haal alle LatLng's uit de array op en maak er een marker van.
	var directionsService = new google.maps.DirectionsService();
	var directionsDisplay = new google.maps.DirectionsRenderer();

	for (i = 0; i < store_locations.length; i++) {
		var marker = new google.maps.Marker({
			position : store_locations[i],
			map : map,
			title : "Leerling: " + (i),
			ZIndex: i
		});
		if (i == 0) {
			marker
					.setIcon(new google.maps.MarkerImage(
							'http://google-maps-icons.googlecode.com/files/factory.png'));
			marker.setTitle("Donald Knuth College");
		}

		// directionsDisplay.setMap(map);
		//
		// var request = {
		// origin: store_locations[0],
		// destination: store_locations[i],
		// travelMode: google.maps.DirectionsTravelMode.DRIVING
		// };
		//
		// directionsService.route(request, function(response, status) {
		// if (status == google.maps.DirectionsStatus.OK) {
		// directionsDisplay.setDirections(response);
		// }
		// });

		google.maps.event
				.addListener(
						marker,
						'click',
						function() {
							// Scott: Hier wordt de infowindow correct geplaatst
							// bij de
							// marker, gevuld en weergegeven bij een klik.
							infowindow.setPosition(this.getPosition());
							if (this.title == "Donald Knuth College") {
								this.title = "<img src='http://confluence.cmi-hro.nl/download/attachments/25266845/DKC.png?version=1&modificationDate=1316002527000' width=196 height=100></img>";
							}
							this.title = this.title + map.markers.length;
							infowindow.setContent(this.title);
							infowindow.open(map, this);
						});
		
	}

	document.getElementById("map_reset_button").style.display = "block";
}
